<template>
    <component :is="comp"></component>
</template>

<script>
import { defineComponent, computed } from "vue-demi";
import { useRouter } from "./vue-router";

export default defineComponent({
    setup() {
        let router = useRouter()
        // router.current是ref响应式对象
        const comp = computed(() => {
            const route = router.route.find((route) => route.path === router.current.value)
            return route ? route.component : null;
        })
        return {
            comp
        }
    }
})
</script>